package com.icinfo.cloud.provider.punish.config.utils;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.icinfo.cloud.common.security.util.UserUtil;

import java.util.Date;
import java.util.HashMap;

/**
 * 描述：审计数据工具
 *
 * @author zhangqiang
 * @date 2022/12/05
 */
public class AuditDataUtil {

    public static void fillAuditAddData(Object o) {
        HashMap<String, Object> param = CollUtil.newHashMap();
        String id =  UserUtil.getUserInfo().getPersonId();
        String realName = UserUtil.getUserInfo().getRealName();
        param.put("createdBy", id);
        param.put("createdByName", realName);
        param.put("createdTime", new Date());
        param.put("updatedBy", id);
        param.put("updatedByName", realName);
        param.put("updatedTime", new Date());
        BeanUtil.copyProperties(param, o);
    }

    public static void fillAuditDataForUpdate(Object o) {
        HashMap<String, Object> param = CollUtil.newHashMap();
        String id =  UserUtil.getUserInfo().getPersonId();
        String realName = UserUtil.getUserInfo().getRealName();
        param.put("updatedBy", id);
        param.put("updatedByName", realName);
        param.put("updatedTime", new Date());
        BeanUtil.copyProperties(param, o);
    }

}
